package org.rasterfun.language2



/**
 * Base class that provides code generation for binary operations.
 * 
 * @author Hans Haggstrom
 */
abstract class BinaryOp[T <: Expression](generatedOp : String, sourceOp : String, a: T, b: T) extends Expression {

	def this(operator: String, a: T, b: T) {
		this(operator, operator, a, b)
	}

  override def children = List(a, b)

	def operatorSymbol: String = sourceOp

  def generateCode(context: Context, s: StringBuilder) {
    s.append(" ( ")
    a.code(context, s)
    s.append(" ")
    s.append(generatedOp)
    s.append(" ")
    b.code(context, s)
    s.append(" ) ")
  }

}
